
<%@page import="study.itwill.common.PatternChecker"%>
<%@page import="study.itwill.team5.board.BoardItem"%>
<%@page import="study.itwill.team5.board.Board"%>
<%@page import="study.itwill.team5.board.BoardCategoryItem"%>
<%@page import="study.itwill.team5.board.BoardCategory"%>
<%@page import="study.itwill.team5.member.MemberItem"%>
<%@page import="study.itwill.team5.member.Member"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ include file="../dbcon.jsp"%>
<%
	String category = request.getParameter("category");

	/** 파라미터의 유효성 검사 */
	if(!PatternChecker.isValue(category)) {
		out.print("<script type='text/javascript'>alert('민박 일련번호 파라미터가 없습니다.');history.back();</script>");
		return;
	}
	
	if(!PatternChecker.isNum(category)) {
		out.print("<script type='text/javascript'>alert('민박 일련번호 파라미터가 형식에 맞지 않습니다.');history.back();</script>");
		return;
	}


	int n_seq = Integer.parseInt(category);
	
	ArrayList<BoardItem> list = (new Board()).listBoard(1,category);

	if (list == null) {
		out.print("<script type='text/javascript> alert('데이터 조회에 실패했습니다. 잠시후 다시 시도해 주세요.'); history.back();</script>");
		return;
	}
%>
<!DOCTYPE html>
<html lang="ko">
<head>
<%@ include file="../head.jsp"%>

</head>


<body>
	<%@ include file="../menu.jsp"%>
	DBHandler.disconnect();

	<div class="container">

		<div class="table-responsive">
			<div class="page-header clearfix">
				<h1 class="pull-left">게시판 목록</h1>
				<div class="pull-right" style="padding-top: 30px">
					<a href="addBoard.jsp" class="btn btn-info">추가하기</a>
				</div>
			</div>

			<div class="table-responsive">
				<table class="table table-striped table-hover">
					<thead>
						<tr class="warning row">
							<th class="text-center col-md-1">번호</th>
							<th class="text-center col-md-1">카테고리</th>
							<th class="text-center col-md-4">제목</th>
							<th class="text-center col-md-2">작성자</th>
							<th class="text-center col-md-1">조회수</th>
							<th class="text-center col-md-1">등록일자</th>
							<th class="text-center col-md-1">수정일자</th>
							<th class="text-center col-md-1"></th>
						</tr>
					</thead>
					<tbody>
						<%
					if (list.size() < 1) {
				%>
						<tr>
							<td colspan="9">
								<p class="text-center text-warning" style="height: 100px">
									저장된 데이터가 없습니다.</p>
							</td>
						</tr>
						<%
					} else {
						for (int i=0; i<list.size(); i++) {
							BoardItem item = list.get(i);
					%>
						<tr class="text-center row">
							<td class="col-md-1"><%=item.getSeq()%></td>
							<td class="col-md-1"><%=item.getCategory_name()%></td>
							<td class="col-md-4"><%=item.getTitle()%></a></td>
							<td class="col-md-2"><%=item.getUser_name()%></td>
							<td class="col-md-1"><%=item.getHit()%></td>
							<td class="col-md-1 small"><%=item.getReg_date().substring(0, 4)%>-<%=item.getReg_date().substring(4, 6)%>-<%=item.getReg_date().substring(6, 8)%><br><%=item.getReg_date().substring(8, 10)%>:<%=item.getReg_date().substring(10, 12)%>:<%=item.getReg_date().substring(12, 14)%></td>
							<td class="col-md-1 small"><%=item.getEdit_date().substring(0, 4)%>-<%=item.getEdit_date().substring(4, 6)%>-<%=item.getEdit_date().substring(6, 8)%><br><%=item.getEdit_date().substring(8, 10)%>:<%=item.getEdit_date().substring(10, 12)%>:<%=item.getEdit_date().substring(12, 14)%></td>
							<td class="col-md-1"><a href="viewBoard.jsp?seq=<%=item.getSeq()%>"
								class="btn btn-primary">정보보기</a></td>
						</tr>
						<%
								}
							}
						%>
					</tbody>
				</table>
			</div>
		</div>
	</div>

	<!-- Javascript -->
	<script src="/italia/assets/js/jquery.js"></script>
	<script src="/italia/assets/js/bootstrap.min.js"></script>
</body>
</html>